home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Information / CSMP Digest / volume 3 / csmp-digest-v3-146 < prev    next >
Text File  |  1996-05-19  |  77KB  |  2,256 lines

  1. C.S.M.P. Digest             Sat, 11 May 96       Volume 3 : Issue 146
  2.  
  3. Today's Topics:
  4.  
  5.         3D Renderer Sources Available
  6.         Bug in Sound.h that could cause YOUR game to crash
  7.         C++ classes & handles
  8.         Hiding the menubar
  9.         How do I determine the directory of my application
  10.         How to flush a file.
  11.         Long Edit Items In Dialogs
  12.         MacOS Queue Utilities sample code
  13.         MacTCP Q: Finding the local host's IP address
  14.         New Mac Programming Web Page
  15.         QuickDraw GX : Developer info at the GX Fan Club
  16.         QuickTime Music Architecture -- Long Delays in Playing Notes
  17.         Temporary Heaps
  18.  
  19.  
  20.  
  21. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  22. (pottier@clipper.ens.fr).
  23.  
  24. The digest is a collection of article threads from the internet
  25. newsgroups comp.sys.mac.programmer.help, csmp.tools, csmp.misc and
  26. csmp.games. It is designed for people who read news semi-regularly and
  27. want an archive of the discussions.  If you don't know what a
  28. newsgroup is, you probably don't have access to it. Ask your systems
  29. administrator(s) for details. If you don't have access to news, you
  30. may still be able to post messages to the group by using a mail server
  31. like anon.penet.fi (mail help@anon.penet.fi for more information).
  32.  
  33. Each issue of the digest contains one or more sets of articles (called
  34. threads), with each set corresponding to a 'discussion' of a particular
  35. subject.  The articles are not edited; all articles included in this digest
  36. are in their original posted form (as received by our news server at
  37. nef.ens.fr).  Article threads are not added to the digest until the last
  38. article added to the thread is at least two weeks old (this is to ensure that
  39. the thread is dead before adding it to the digest).  Article threads that
  40. consist of only one message are generally not included in the digest.
  41.  
  42. The digest is officially distributed by two means, by email and ftp.
  43.  
  44. If you want to receive the digest by mail, send email to listserv@ens.fr
  45. with no subject and one of the following commands as body:
  46.     help                        Sends you a summary of commands
  47.     subscribe csmp-digest Your Name    Adds you to the mailing list
  48.     signoff csmp-digest            Removes you from the list
  49. Once you have subscribed, you will automatically receive each new
  50. issue as it is created.
  51.  
  52. The official ftp info is ftp://ftp.dartmouth.edu/pub/csmp-digest.
  53. Questions related to the ftp site should be directed to
  54. scott.silver@dartmouth.edu.
  55.  
  56. -------------------------------------------------------
  57.  
  58. >From gav@mag1.magmacom.com (Gavriel State)
  59. Subject: 3D Renderer Sources Available
  60. Date: 19 Apr 1996 03:54:02 -0400
  61. Organization: none
  62.  
  63. My WatRend scanline-based 3D rendering engine is available for 
  64. downloading at http://www.magmacom.com/~gav/
  65.  
  66. WatRend is portable, having run on Macintoshes, SGI machines, 
  67. x86 DOS, and Linux.  It supports both fixed-point and floating-point
  68. math.  
  69.  
  70. It reads Rend386 format .plg files.
  71.  
  72. Share and Enjoy.
  73.  
  74. --
  75.      Gavriel State | Macintosh Software Engineer | Corel Corporation
  76. - ------------------------------------------------------------------------
  77.             I don't speak for Corel...at least, I usually don't.
  78.  
  79.  
  80. ---------------------------
  81.  
  82. >From Jamie Osborne <jwo@apple.com>
  83. Subject: Bug in Sound.h that could cause YOUR game to crash
  84. Date: Thu, 18 Apr 1996 15:28:03 -0800
  85. Organization: Apple Computer, Inc.
  86.  
  87. There is a nasty bug in Sound.h where a function is returning a structure 
  88. instead of a long as declared in the header.  This can cause odd crashes on 
  89. some machines.  There will be a tech note out on it soon.
  90.  
  91. The way it's declared:
  92. extern pascal long SndSoundManagerVersion(void)
  93.  
  94. The way it should be:
  95. extern pascal NumVersion SndSoundManagerVersion(void)
  96.  
  97.  
  98. Please edit your Sound.h file.  This bug doesn't evince itself immediately, 
  99. and cause cause interesting behaviors, such as crashing the second time you 
  100. run your app.  It has already bitten a couple of developers.
  101.  
  102. Take heed.
  103.  
  104.  
  105. -Jamie Osborne
  106. Sprocket Engineer, Apple Game Technology Group
  107.  
  108.  
  109. +++++++++++++++++++++++++++
  110.  
  111. >From Hiep Dam <starlabs@earthlink.net>
  112. Date: Fri, 19 Apr 1996 00:35:26 -0700
  113. Organization: Earthlink stinks - don't suscribe!
  114.  
  115. Jamie Osborne wrote:
  116. > There is a nasty bug in Sound.h where a function is returning a structure
  117. > instead of a long as declared in the header.  This can cause odd crashes on
  118. > some machines.  There will be a tech note out on it soon.
  119. > The way it's declared:
  120. > extern pascal long SndSoundManagerVersion(void)
  121. > The way it should be:
  122. > extern pascal NumVersion SndSoundManagerVersion(void)
  123. > Please edit your Sound.h file.  This bug doesn't evince itself immediately,
  124. > and cause cause interesting behaviors, such as crashing the second time you
  125. > run your app.  It has already bitten a couple of developers.
  126. > Take heed.
  127.  
  128. Silly me. And all this time I thought it was a "feature"...
  129.  
  130. (not to mention all the time I spent trying to typecast a numversion to long 
  131. to numversion* to long* maybe to numversion** to *long etc. to get the 
  132. "feature" to work. Of course, it didn't work. And I thought it was me. Silly, 
  133. silly, silly. I will be looking for such "features" next time...)
  134.  
  135. Thanks for the info though.
  136. -- 
  137. Hiep "there's no 'Van' in my name" Dam
  138. --
  139. { starlabs@earthlink.net/starlabs@aol.com }
  140. --
  141. "Programmer, debug thyself"
  142.  
  143.  
  144. +++++++++++++++++++++++++++
  145.  
  146. >From dalawren@netcom.com (David Lawrence)
  147. Date: Fri, 19 Apr 1996 09:46:51 GMT
  148. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  149.  
  150. In article <3176D003.34B3@apple.com>, jwo@directory.apple.com wrote:
  151.  
  152. > There is a nasty bug in Sound.h where a function is returning a structure 
  153. > instead of a long as declared in the header.  This can cause odd crashes on 
  154. > some machines.  There will be a tech note out on it soon.
  155. > The way it's declared:
  156. > extern pascal long SndSoundManagerVersion(void)
  157. > The way it should be:
  158. > extern pascal NumVersion SndSoundManagerVersion(void)
  159. > Please edit your Sound.h file.  This bug doesn't evince itself immediately, 
  160. > and cause cause interesting behaviors, such as crashing the second time you 
  161. > run your app.  It has already bitten a couple of developers.
  162. > Take heed.
  163.  
  164.  
  165.  
  166. It got me, too.
  167.  
  168. Note: this bug is only in the Universal Headers on CW8 and ETO 18.  The
  169. prototypes were correct in CW7 / ETO 17 and earlier, and they are
  170. supposedly fixed in the ETO 19 Universal Headers.
  171.  
  172.  
  173.     David Lawrence
  174.     Future Tense
  175.  
  176.  
  177. +++++++++++++++++++++++++++
  178.  
  179. >From mattm@apple.com (Matthew Melmon)
  180. Date: 22 Apr 1996 22:15:43 GMT
  181. Organization: Apple Computer
  182.  
  183. In article <dalawren-1904960246510001@192.0.2.1>, dalawren@netcom.com
  184. (David Lawrence) wrote:
  185.  
  186. > In article <3176D003.34B3@apple.com>, jwo@directory.apple.com wrote:
  187. > > There is a nasty bug in Sound.h where a function is returning a structure 
  188. > > instead of a long as declared in the header.
  189.  
  190. > Note: this bug is only in the Universal Headers on CW8 and ETO 18.  The
  191. > prototypes were correct in CW7 / ETO 17 and earlier, and they are
  192. > supposedly fixed in the ETO 19 Universal Headers.
  193.  
  194. The change to long was intentional, and the result of a
  195. misunderstanding about return values on the Power Macintoshes
  196. fitting into registers.  It was set back to NumVersion as of
  197. ETO 19.
  198.  
  199.  
  200. ---------------------------
  201.  
  202. >From David T Mcwherter <dtm+@andrew.cmu.edu>
  203. Subject: C++ classes & handles
  204. Date: Tue,  9 Apr 1996 07:27:24 -0400
  205. Organization: Freshman, Mathematics, Carnegie Mellon, Pittsburgh, PA
  206.  
  207.     I'm trying to write a C++ app, and everything's working rather
  208. nicely, except for one little dilemna.
  209.     I'd like to create my objects in handles, not pointers.
  210.     I think know how to use the new function to return a pointer to a class,
  211.         myClassPtr = new Class();
  212. and when I do this, everything works nicely and my constructor gets
  213. called.  Conversely, when I use delete, my destructor is called.
  214.     Is there a way to put the object into (and conversely delete) a
  215. macintosh relocatable handle so that all the C++ niceties still work
  216. (ie: constructor, destructor called automatically)?
  217.     Also, what would be the conventions for locking the handle?  Would I
  218. lock before a call to a function in the class, or could I call it
  219. afterwards, inside the function?
  220.  
  221. PS: I'm using metrowerks codewarrior
  222.  
  223. Thanks,
  224. -David McWherter
  225. dtm+@andrew.cmu.edu
  226. http://abduction.res.cmu.edu
  227.  
  228. I want to die peacefully, in my sleep, like my grandfather, not
  229. screaming, terrified, like his passengers.  
  230.  
  231. +++++++++++++++++++++++++++
  232.  
  233. >From jennings@halcyon.com (James Jennings)
  234. Date: Tue, 09 Apr 1996 18:20:52 -0700
  235. Organization: Northwest Nexus Inc.
  236.  
  237. In article <slOYaQO00iVEE1EFNt@andrew.cmu.edu>, David T Mcwherter
  238. <dtm+@andrew.cmu.edu> wrote:
  239.  
  240. >     Is there a way to put the object into (and conversely delete) a
  241. > macintosh relocatable handle so that all the C++ niceties still work
  242. > (ie: constructor, destructor called automatically)?
  243.  
  244. I did that once. I can send you my source if you're interested.
  245.  
  246. It's basically an "envelope" template class that handles the Handle. The
  247. envelope has a Lock() and Unlock() method, and creates and disposes of the
  248. Handle.
  249.  
  250. There are three key tricks:
  251.  
  252. 1) In new.h there is a version of new() that doesn't allocate it's own
  253. memory. It's called from the envelope's constructor like this:
  254.    mObject = ::NewHandle(sizeof(Type));
  255.    Type *t = new (*mObject) Type; // triggers Type's constructor...
  256.  
  257. 2) It's possible to call an object's destructor directly. The envelope's
  258. destructor does this.
  259.    (*(Type**)mObject)->Type::~Type(); // trigger the destructor...
  260.    ::DisposeHandle(mObject);
  261.  
  262. 3) By supplying an operator->() you can make the envelope look like a
  263. pointer to the object that is actually in the handle.
  264.    Type * operator->(void) { return *(Type**)(theObject); } 
  265.  
  266. Use it like this.
  267.    ObjectHandle<A>   oha; // declare the envelope: A constructor called.
  268.    oha.Lock();
  269.    oha->Foo();   // calls A::Foo()
  270.    oha.Unlock();
  271.  
  272. When oha goes out of scope it's destructor (and A's destructor) is called.
  273.  
  274. James
  275.  
  276. +++++++++++++++++++++++++++
  277.  
  278. >From gurgle@apple.com (Pete Gontier)
  279. Date: Wed, 10 Apr 1996 14:53:59 -0800
  280. Organization: Apple Computer, Inc.
  281.  
  282. In article <slOYaQO00iVEE1EFNt@andrew.cmu.edu>,
  283. David T Mcwherter <dtm+@andrew.cmu.edu> wrote:
  284.  
  285.  > Is there a way to put the object into (and conversely delete) a
  286.  > macintosh relocatable handle so that all the C++ niceties still work
  287.  > (ie: constructor, destructor called automatically)?
  288.  
  289. No.
  290.  
  291.  > Also, what would be the conventions for locking the handle?  Would I
  292.  > lock before a call to a function in the class, or could I call it
  293.  > afterwards, inside the function?
  294.  
  295. My guess would be that you'd want to lock before making a call, since the
  296. called code might be in another segment, and by the time the member
  297. function executed, the 'this' pointer might already be invalid.
  298.  
  299. However, compilers won't cooperate with you on this one. They would have
  300. to call HLock on their own, especially in the case of constructors, since
  301. C++ syntax doesn't give you an opportunity to lock between the time the
  302. object's memory block is allocated and its constructor is called. I
  303. suppose you could write your own allocator which locked the handle just
  304. after allocating it, but then all your constructors would be mysteriously
  305. unlocking 'this' just before they returned, and heaven help you if you
  306. ever forgot.
  307.  
  308. You CAN put SOME objects in handles, but you only get to use a sub-set of
  309. C++ functionality with such objects. There's a section on this in one of
  310. your compiler manuals.
  311.  
  312. To learn more about why you can't do real C++ with handle objects, check out:
  313.  
  314.     <URL:http://dev.info.apple.com/technotes/tn1009.html>
  315.  
  316. - -
  317.  
  318.   Pete Gontier, Integer Poet, Apple Macintosh Developer Technical Support
  319.  
  320.   work      mail  <mailto:gurgle@apple.com>
  321.   personal  mail  <mailto:gurgle@ccnet.com>
  322.   personal  web   <http://www.ccnet.com/~gurgle>
  323.   work      web   <http://dev.info.apple.com/dts.html>
  324.  
  325. +++++++++++++++++++++++++++
  326.  
  327. >From "Etay Bogner" <etay@vocaltec.com>
  328. Date: 11 Apr 96 14:47:28 +0000
  329. Organization: Princeton Plasma Physics Laboratory
  330.  
  331. Just derive it from HandleObject, an internal "class" that metrowerks has
  332. for backward compatibility with old MacApp's I guess.
  333.  
  334. Besides that I guess that it acts as a PascalObject rather than a C++
  335. object in that that you have to supply an "Initialize" method that will do
  336. the actual construction.
  337.  
  338. Anyway, try it and find out.
  339.  
  340. Etay.
  341. - -------------------------------------------------
  342. This message was created and sent using the Cyberdog Mail System
  343. - -------------------------------------------------
  344.  
  345.  
  346. +++++++++++++++++++++++++++
  347.  
  348. >From tulip@tiac.net (Ed Anson)
  349. Date: Fri, 12 Apr 1996 21:55:16 -0400
  350. Organization: Tulip Software
  351.  
  352. In article <slOYaQO00iVEE1EFNt@andrew.cmu.edu>, David T Mcwherter
  353. <dtm+@andrew.cmu.edu> wrote:
  354.  
  355. >     I'd like to create my objects in handles, not pointers.
  356.  
  357. Most Macintosh C++ compilers support a non-standard extension, which
  358. provides a builtin class called HandleObject. [I'm not positive about the
  359. spelling.] Simply derive your classes from this and you will get what you
  360. want. The compiler takes care of most of the problems of using handles for
  361. objects.
  362.  
  363. >     Also, what would be the conventions for locking the handle?  Would I
  364. > lock before a call to a function in the class, or could I call it
  365. > afterwards, inside the function?
  366.  
  367. Typically, one does not lock handle based objects. In principle, you don't
  368. know that they are implemented as handles and don't have a supported way
  369. to obtain the actual handle. (Of course, we all know how to do it, but we
  370. shouldn't.)
  371.  
  372. The compiler automatically dereferences twice for every access to a field.
  373. This means that the handle doesn't need to be locked. The only caveat is
  374. that you can't pass pointers to fields as parameters to functions. Doing
  375. so causes nasty and unpredictable crashes. You also cannot use multiple
  376. inheritance with handle based objects.
  377.  
  378. BTW: I don't recommend doing this. The support is there to enable
  379. compilation of old versions of MacApp. Even MacApp has migrated away from
  380. handles and instead uses a much more efficient memory allocation scheme. I
  381. generally find that the default new and delete commands (usually
  382. implemented using malloc and free) do better than handles.
  383.  
  384. - --------------------
  385. Ed Anson
  386. Tulip Software
  387. Andover, MA 01810   Check out my WWW page:
  388. U.S.A.              <http://www.tiac.net/users/tulip/home.html>
  389.  
  390. +++++++++++++++++++++++++++
  391.  
  392. >From deirdre@sover.net (Deirdre)
  393. Date: Sat, 13 Apr 1996 11:39:05 -0400
  394. Organization: Not hardly
  395.  
  396. In addition to everything that's been said on this, it occurs to This
  397. Humble Person that one might want to create a block of objects as one
  398. discrete handle. For one thing, when you allocated it you could HLockHi
  399. and, when needed, do the same again.
  400.  
  401. For example, if you had an LSingleDoc which has an LWindow and an LFile
  402. and you know this specific window will have ten objects of known size, you
  403. could allocate it as one contiguous block. It could allocate other stuff
  404. too if it needed it.
  405.  
  406. It would be a nightmare to figure out, but the group allocation idea does
  407. have some merits. I would expect that you'd keep it locked most of the
  408. time, but if you had problems with fragmenting the ability to move the
  409. block could be a plus.
  410.  
  411. Just a thought.
  412.  
  413. _Deirdre
  414.  
  415. http://www.sover.net/~deirdre
  416.  
  417.  
  418. +++++++++++++++++++++++++++
  419.  
  420. >From Paulo Casanova <l41188@alfa.ist.utl.pt>
  421. Date: Sun, 14 Apr 1996 16:14:17 +0000
  422. Organization: Instituto Superior Tecnico 
  423.  
  424.  
  425. > In addition to everything that's been said on this, it occurs to This
  426. > Humble Person that one might want to create a block of objects as one
  427. > discrete handle. For one thing, when you allocated it you could HLockHi
  428. > and, when needed, do the same again.
  429. [...]
  430. > It would be a nightmare to figure out, but the group allocation idea 
  431. does
  432. > have some merits. I would expect that you'd keep it locked most of the
  433. > time, but if you had problems with fragmenting the ability to move the
  434. > block could be a plus.
  435. > Just a thought.
  436. > _Deirdre
  437.  
  438.   I really don't think it would be that complicated. If you have an 
  439. object of type A 2 objects of type B you could make:
  440.  
  441. typedef struct
  442. {
  443.   A a;
  444.   B, b1, b2;
  445. } x;
  446.  
  447.   Then allocated 1 struct of type x and call the constructors... doesn't 
  448. sound complicated to me (only sounds very little cientific...)
  449.  
  450. Paulo
  451.  
  452. - ----------------------------------------------------------------------------
  453. All rights reserved by the author. Unauthorised copying, hiring, lending or
  454. broadcasting of this message prohibited. Exception: you can use my text for
  455. replys to me or to the place where I have posted the message.
  456. - ----------------------------------------------------------------------------
  457.  
  458.  
  459.  
  460. +++++++++++++++++++++++++++
  461.  
  462. >From Paulo Casanova <l41188@alfa.ist.utl.pt>
  463. Date: Mon, 15 Apr 1996 20:21:09 +0000
  464. Organization: Instituto Superior Tecnico 
  465.  
  466. > What I meant (that was a nightmare) was that if you had pointers to stuff
  467. > in this block and the block moved....well you'd have to find a way to
  468. > account for that. You could have a msg_BlockMoving or some such that
  469. > trickled through the appropriate places though.
  470.  
  471.   Yes, but supposed you had locked the handle and in that case you had no 
  472. problems with pointers. Of course you could unlock the handle in specific 
  473. cases and had to findout an "information" mechanism. Doesn't sound very, 
  474. very complicated. But it's not simple, anyway...
  475.  
  476. Paulo
  477.  
  478. - ----------------------------------------------------------------------------
  479. All rights reserved by the author. Unauthorised copying, hiring, lending or
  480. broadcasting of this message prohibited. Exception: you can use my text for
  481. replies to me or to the place where I have posted the message.
  482. - ----------------------------------------------------------------------------
  483.  
  484.  
  485. +++++++++++++++++++++++++++
  486.  
  487. >From deirdre@sover.net (Deirdre)
  488. Date: Sun, 14 Apr 1996 21:49:01 -0400
  489. Organization: Not hardly
  490.  
  491. What I meant (that was a nightmare) was that if you had pointers to stuff
  492. in this block and the block moved....well you'd have to find a way to
  493. account for that. You could have a msg_BlockMoving or some such that
  494. trickled through the appropriate places though.
  495.  
  496. _Deirdre
  497.  
  498. In article <Pine.OSF.3.91.960414161128.25012D-100000@alfa.ist.utl.pt>,
  499. Paulo Casanova <l41188@alfa.ist.utl.pt> wrote:
  500.  
  501. > I really don't think it would be that complicated. If you have an 
  502. > object of type A 2 objects of type B you could make:
  503.  
  504. http://www.sover.net/~deirdre
  505.  
  506. +++++++++++++++++++++++++++
  507.  
  508. >From deirdre@sover.net (Deirdre)
  509. Date: Mon, 15 Apr 1996 18:37:34 -0400
  510. Organization: Not hardly
  511.  
  512. Right, but I was talking about a chunk of objects in one handle. Do you
  513. know every object that knows where your object is and can you update their
  514. reference?
  515.  
  516. This is the issue as I see it. Not simple.
  517.  
  518. _Deirdre
  519.  
  520. In article <Pine.OSF.3.91.960415201929.5653D-100000@alfa.ist.utl.pt>,
  521. Paulo Casanova <l41188@alfa.ist.utl.pt> wrote:
  522.  
  523. > Yes, but supposed you had locked the handle and in that case you had no 
  524. > problems with pointers. Of course you could unlock the handle in specific 
  525. > cases and had to findout an "information" mechanism. Doesn't sound very, 
  526. > very complicated. But it's not simple, anyway...
  527.  
  528. http://www.sover.net/~deirdre
  529.  
  530.  
  531. +++++++++++++++++++++++++++
  532.  
  533. >From Paulo Casanova <l41188@alfa.ist.utl.pt>
  534. Date: Tue, 16 Apr 1996 16:13:26 +0000
  535. Organization: Instituto Superior Tecnico 
  536.  
  537.  
  538. > Right, but I was talking about a chunk of objects in one handle. Do you
  539. > know every object that knows where your object is and can you update their
  540. > reference?
  541. > This is the issue as I see it. Not simple.
  542. > _Deirdre
  543.  
  544.   Suppose you create a handle with n objects. Instead of referencing each 
  545. object with a pointer, you could reference it with a handle and 
  546. (possibly) an index.
  547.   If you want to call the object all you had to do is to lock the handle 
  548. and call it. You don't have to lock it if you're sure no memory will move.
  549.  
  550.   The best way do implement this is directly by the compiler. It is 
  551. slower but it would be very memory-friendly.
  552.   If I'm not mistaken, THINK C 6.0 implements objects as a C extension 
  553. and allows you to do this.
  554.  
  555.   Obvioulsy a C++ program like this is very inneficient (think about 
  556. having to lock a handle each time you want to call an object's method...)
  557.  
  558.   What I would suggest is somehow different: the program would create 
  559. only objects in the application's heap. Each object created (as a mac 
  560. locked handle - each object would have to overload the new operator) would 
  561. "register" itself in a "central" database.
  562.   There would be a handle with all pointers to all objects and there 
  563. would be nothing else in the heap (except some handles if you wish).
  564.   When the program runs out of memory (probably due to memory 
  565. fragmentation), every object's handle is released and CompactMem() is 
  566. called. Since everything in the heap are handles the heap would now be 
  567. perfecly defragmented. Since we had in the "main" database all pointers 
  568. of objects and all handles to them we know the old values of the 
  569. pointers, the new values of the pointers and were every obejct is.
  570.   Now we would lock every object again and give each object a message to 
  571. update it's pointers. Then, each object would search in it's database all 
  572. pointers it has and updates them all. After this, all pointers point to 
  573. correct memory locations... how about this?
  574.  
  575. Paulo
  576.  
  577. - ----------------------------------------------------------------------------
  578. All rights reserved by the author. Unauthorised copying, hiring, lending or
  579. broadcasting of this message prohibited. Exception: you can use my text for
  580. replies to me or to the place where I have posted the message.
  581. - ----------------------------------------------------------------------------
  582.  
  583.  
  584.  
  585. +++++++++++++++++++++++++++
  586.  
  587. >From sw@nan.co.uk (Sak Wathanasin)
  588. Date: Tue, 16 Apr 1996 12:05:40 GMT
  589. Organization: Network Analysis Ltd
  590.  
  591. In article <deirdre-1304961139080001@pm0a15.new.sover.net>,
  592. deirdre@sover.net (Deirdre) wrote:
  593.  
  594. > For example, if you had an LSingleDoc which has an LWindow and an LFile
  595. > and you know this specific window will have ten objects of known size, you
  596. > could allocate it as one contiguous block. It could allocate other stuff
  597. > too if it needed it.
  598.  
  599. If there is a known, fixed number, why not simply embed the 10 objects in
  600. your LWindow object? Then when you allocate the latter, you allocate the
  601. 10 embedded objects as well. Or am I missing something?
  602.  
  603. -- 
  604. Sak Wathanasin
  605. Network Analysis Limited
  606. 178 Wainbody Ave South, Coventry CV3 6BX, UK
  607.  
  608. Internet: sw@nan.co.uk 
  609. uucp:     ...!britain.eu.net!nan!sw
  610. Phone: (+44) 1203 419996                              Fax: (+44) 1203 690690
  611.  
  612. +++++++++++++++++++++++++++
  613.  
  614. >From S.W.Lay@damtp.cam.ac.uk (Steve Lay)
  615. Date: Wed, 24 Apr 1996 09:58:08 +0100
  616. Organization: DAMTP, Cambridge University
  617.  
  618. All this talk of C++ classes and handles reminded me of some code that I
  619. wrote a long time ago (but have maintained every now and then for years). 
  620. I've never liked the idea of the 'hidden' implementation and, at the time,
  621. wasn't confident enough with templates (and nor was my compiler) to
  622. produce an elegant 'Handle envelope' solution like one of the previous
  623. posters.
  624.  
  625. As a result of this discussion I went back and looked at the code for the
  626. class which provides 'handle-based' objects.  When I first programmed in
  627. C++ 
  628. I naively assumed that the pointer returned by the allocator was the
  629. pointer that I was using for my object.  When multiple inheritance came
  630. along I realised my mistake but I didn't get round to upgrading the code
  631. to cope until sometime last year.
  632.  
  633. A feature which would be nice is the ability to allocate whole arrays of
  634. objects using one handle - sadly CW7 doesn't allow my approach to be
  635. trivially extended to do this.  On the other hand, I did 'work in' support
  636. for using temporary memory.
  637.  
  638. I've recently got round to the process of documenting my code (I know, I
  639. know...) and so, for what it's worth, I've stuck a page up on the web from
  640. where it can be seen:
  641.  
  642. http://www.amtp.cam.ac.uk/icrd/SCL/
  643.  
  644. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  645. Steve Lay                                ICRD Group (Cambridge)
  646.  
  647. email:  S.W.Lay@damtp.cam.ac.uk                           DAMTP
  648. WWW:    http://www.amtp.cam.ac.uk/icrd/           Silver Street
  649. Phone:  (01223) 337851                                Cambridge
  650. Fax:    (01223) 337918                                  CB3 9EW
  651. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  652.  
  653. ---------------------------
  654.  
  655. >From jalvarad@galaxy.csc.calpoly.edu (Javier Alvarado)
  656. Subject: Hiding the menubar
  657. Date: 20 Apr 1996 08:09:34 GMT
  658. Organization: Cal Poly Computer Science Dept.
  659.  
  660. What do I have to do to hide the menubar? I have tried setting the menubar 
  661. height to zero and then calling InvalMenubar() but it isn't erased.
  662.  
  663. Thanks for any help.
  664.  
  665.  
  666. +++++++++++++++++++++++++++
  667.  
  668. >From Wintermute@iamug.org
  669. Date: Sat, 20 Apr 96 07:42:40 CST
  670. Organization: Mouse Hole BBS
  671.  
  672. You have to add the freed-up space to whatever window you'd like to cover up the
  673. menu bar with. Apple has an excellent example of this at their ftp site!!
  674.  
  675.  
  676. Josh
  677.  
  678.  
  679. Mouse Hole Server - Des Moines Iowa
  680.  
  681. +++++++++++++++++++++++++++
  682.  
  683. >From Steve Makohin <WaterEdgSW@aol.com>
  684. Date: 21 Apr 1996 19:54:33 GMT
  685. Organization: Water's Edge Software
  686.  
  687. In article <4la63u$oqa@waldorf.csc.calpoly.edu> Javier Alvarado,
  688. jalvarad@galaxy.csc.calpoly.edu writes:
  689. >What do I have to do to hide the menubar? I have tried setting the menubar 
  690. >height to zero and then calling InvalMenubar() but it isn't erased.
  691.  
  692. What you are missing is adding the menu bar's region to your "gray
  693. region" and invalidating the area that used to be under your menu bar.
  694.  
  695. If you want to hide the menu bar in one line of code (and have everything
  696. work flawlessly), peek into the Tools Plus 3.0 (application development
  697. libraries) evaluation kit on the nets. Tools Plus was rated 4 stars by
  698. Macworld magazine.
  699.  
  700. -Steve Makohin
  701.  Water's Edge Software
  702.  
  703. - -------
  704. For a fast reply, send an email to: WaterEdgSW@aol.com
  705.  
  706.  
  707. +++++++++++++++++++++++++++
  708.  
  709. >From bolsinga@tezcat.com (Greg Bolsinga)
  710. Date: Mon, 22 Apr 1996 00:48:46 -0500
  711. Organization: Lo Fi Software
  712.  
  713. If you have Quicktime 2.1 installed, there's now an API for it. I don't
  714. remember the name however. 
  715.  
  716. And as a really cool thing: if you ask for say, 640x480, and a multisync
  717. monitor is attached, and at a different screen ratio than the one you ask
  718. for, it will change the screen ratio for you when it hides the menu bar!
  719.  
  720. Greg Bolsinga
  721.  
  722. -- 
  723. Greg Bolsinga
  724. bolsinga@tezcat.com
  725. What's a Theremin?
  726.  
  727.  
  728. +++++++++++++++++++++++++++
  729.  
  730. >From philnaz@tribeca.ios.com (Phil Nasadowski)
  731. Date: 22 Apr 1996 21:32:21 GMT
  732. Organization: None
  733.  
  734. In article <0013AFDF.fc@iamug.org>, Wintermute@iamug.org wrote:
  735.  
  736. > You have to add the freed-up space to whatever window you'd like to
  737. cover up >the
  738. > menu bar with. Apple has an excellent example of this at their ftp site!!
  739.  
  740. Which makes me wonder why Apple doesn't just make a stupid toolbox routine
  741. to do this - I mean, it's not like it would never be called (and a lot
  742. more useful than that PackBits() one, I STILL can't figure out what the
  743. heck that does...)
  744. I think by now (and for the last 5 years), getting rid of the menubar has
  745. become and acepted thing on the Macintosh.  Why can't Apple just give us
  746. more useful routines for real stuff like hideing the menu bar..
  747.  
  748.  
  749. +++++++++++++++++++++++++++
  750.  
  751. >From mouser@zercom.net (Martin-Gilles Lavoie)
  752. Date: Tue, 23 Apr 1996 11:10:54 -0500
  753. Organization: Groupimage, inc.
  754.  
  755. In article <4la63u$oqa@waldorf.csc.calpoly.edu>,
  756. jalvarad@galaxy.csc.calpoly.edu (Javier Alvarado) wrote:
  757.  
  758. > What do I have to do to hide the menubar? I have tried setting the menubar 
  759. > height to zero and then calling InvalMenubar() but it isn't erased.
  760.  
  761. This has got to be the #1 FAQ.
  762.  
  763. Setting the menu bar height to zero isn't enough, since the grayRegion
  764. (the desktop) requires to be grown (and shrunk back when re-showing the
  765. mbar) so that it can draw where the menu bar was before.
  766.  
  767. In the following code, you'll see what's required for you to properly
  768. change the menu bar height.
  769.  
  770. (Most obviously, this code is out of my own framework, and you'll have
  771. play with it a bit, since you do not have the class' definition.  Though,
  772. the basics of the code you need is there.)
  773.  
  774. void    TMenuManager::HideMenuBar   (void) {
  775.     Rect        mBarRect    =   {0,0,0,0};
  776.     RgnHandle   grayRegion  =   nil;
  777.     
  778.     if (!this->fMBarHidden) {
  779.         this->fOldMBarHeight    =   LMGetMBarHeight();
  780.         
  781.         LMSetMBarHeight(0);
  782.         
  783.         SetRect(    &mBarRect,
  784.                     qd.screenBits.bounds.left,
  785.                     qd.screenBits.bounds.top,
  786.                     qd.screenBits.bounds.right,
  787.                     qd.screenBits.bounds.top + this->fOldMBarHeight);
  788.         
  789.         this->fMBarRgn  =   NewRgn();
  790.         
  791.         RectRgn(this->fMBarRgn, &mBarRect);
  792.         
  793.         grayRegion = GetGrayRgn();
  794.         
  795.         UnionRgn(grayRegion, this->fMBarRgn, grayRegion);
  796.         
  797.         PaintOne(nil, this->fMBarRgn);
  798.         
  799.         this->fMBarHidden   =   true;
  800.         
  801.         DrawMenuBar();
  802.     }
  803. }
  804.  
  805. void    TMenuManager::ShowMenuBar   (void) {
  806.     RgnHandle       grayRegion  =   nil;
  807.     
  808.     if (this->fMBarHidden) {
  809.         LMSetMBarHeight(this->fOldMBarHeight);
  810.         
  811.         grayRegion  =   GetGrayRgn();
  812.         
  813.         DiffRgn(grayRegion, this->fMBarRgn, grayRegion);
  814.         
  815.         DisposeRgn(this->fMBarRgn);
  816.         
  817.         this->fMBarRgn  =   nil;
  818.         
  819.         this->fMBarHidden   =   false;
  820.         
  821.         DrawMenuBar();
  822.     }
  823. }
  824.  
  825. -- 
  826. Martin-Gilles Lavoie
  827.  
  828. [CYRNFR QB ABG ZVK BE BGUREJVFR NYGRE GUR OVGF VA GUVF ZRFFNTR.]
  829.  
  830. +++++++++++++++++++++++++++
  831.  
  832. >From Duane Maxwell <dmaxwell@gryphonsw.com>
  833. Date: Tue, 23 Apr 1996 15:58:40 -0700
  834. Organization: Gryphon Software Corporation
  835.  
  836. >Which makes me wonder why Apple doesn't just make a stupid toolbox routine
  837. >to do this - I mean, it's not like it would never be called
  838.  
  839. Wonder no more - there is such a call in QuickTime 2.1.  It takes care of the menu bar 
  840. and the control strip.  I belive Sprockets also supports such a call.
  841.  
  842.  
  843. +++++++++++++++++++++++++++
  844.  
  845. >From blob@ccnet.com
  846. Date: Wed, 24 Apr 1996 20:23:29 -0700
  847. Organization: CCnet Communications (510-988-7140 guest)
  848.  
  849. In article <philnaz-2204961731370001@ppp-56.ts-3.nyc.idt.net>,
  850. philnaz@tribeca.ios.com (Phil Nasadowski) wrote:
  851. >Which makes me wonder why Apple doesn't just make a stupid toolbox routine
  852. >to [hide the menu bar]
  853.  
  854. QuickTime 2.1 and later contains a call to hide the menu bar, control
  855. strip, and any other "stuff" that might interfer with a movie (or game,
  856. etc.)  See the QuickTime 2.1 documentation for details.
  857.  
  858. ---------------------------
  859.  
  860. >From bforney@umich.edu (Brian Forney)
  861. Subject: How do I determine the directory of my application
  862. Date: Thu, 18 Apr 1996 22:33:27 -0400
  863. Organization: University of Michigan, College of Engineering
  864.  
  865. Hi. I'd like to read a file that's in the same directory as my application
  866. without using the standard file dialog package. Is there some way to do
  867. this? I've looked at the Inside Macintosh File volume, but I haven't found
  868. anything that would even hint at this. If there's a FAQ on this, please
  869. point me to it.
  870.  
  871. Thanks,
  872. Brian Forney
  873. bforney@umich.edu
  874.  
  875. +++++++++++++++++++++++++++
  876.  
  877. >From hina@cod.nosc.mil (Dave Hina)
  878. Date: Fri, 19 Apr 1996 09:10:57 -0700
  879. Organization: SAIC at NRaD
  880.  
  881. In article <bforney-1804962233270001@grimmy.reshall.umich.edu>,
  882. bforney@umich.edu wrote:
  883.  
  884.  > Hi. I'd like to read a file that's in the same directory as my application
  885.  > without using the standard file dialog package. Is there some way to do
  886.  > this? I've looked at the Inside Macintosh File volume, but I haven't found
  887.  > anything that would even hint at this. If there's a FAQ on this, please
  888.  > point me to it.
  889.  > 
  890. Try using the Process Manager's GetProcessInfo() to obtain the FSSpec of your
  891. application. Then replace the file name with that of the file you want to read.
  892.  
  893. Dave
  894.  
  895. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  896. +                            Dave Hina                              +
  897. +                          SAIC at  NRaD                            +
  898. +                          San Diego, CA                            +
  899. +              email: hina@cod.nosc.mil, daverh@aol.com             +
  900. +                 p: 619-553-5187   f: 619-553-4732                 +
  901. +                        Opinions == mine!                          +
  902. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  903.  
  904.  
  905. +++++++++++++++++++++++++++
  906.  
  907. >From aevans@sicolamartin.com (Allan Evans)
  908. Date: Fri, 19 Apr 1996 09:35:33 -0500
  909. Organization: SicolaMartin
  910.  
  911. In article <bforney-1804962233270001@grimmy.reshall.umich.edu>, Brian
  912. Forney (bforney@umich.edu) wrote:
  913.  
  914. > Hi. I'd like to read a file that's in the same directory as my application
  915. > without using the standard file dialog package. Is there some way to do
  916. > this? I've looked at the Inside Macintosh File volume, but I haven't found
  917. > anything that would even hint at this. If there's a FAQ on this, please
  918. > point me to it.
  919. > Thanks,
  920. > Brian Forney
  921. > bforney@umich.edu
  922.  
  923. Try PBDTGetAPPL (IM Mac Toolbox Essentials, Ch. 7) - one of the parameters
  924. returned is the parent directory ID, which you could then use to create a
  925. filespec with FSMakeFSSpec to open your file. Hope that helps...
  926.  
  927. - Allan
  928.  
  929. -- 
  930. Allan Evans     aevans@sicolamartin.com,   allane1@onr.com 
  931. Interactive Programmer, SicolaMartin  -  Austin, TX, USA
  932. (512) 502-4529
  933. Ask me about Magnet...
  934. "No matter where you go, there you are.' - BB
  935.  
  936. +++++++++++++++++++++++++++
  937.  
  938. >From bzuk@telerama.lm.com (Brian Zuk)
  939. Date: Fri, 19 Apr 1996 13:07:58 -0400
  940. Organization: Telerama Public Access Internet, Pittsburgh, PA
  941.  
  942.   I use this at startup.
  943.  
  944. Brian Zuk
  945.  
  946.    SInt16            vRefNum;
  947.    WDPBRec           wdr;
  948.    FSSpec            spec;
  949.    
  950.    GetVol(NULL, &vRefNum);
  951.    wdr.ioNamePtr = spec.name;
  952.    wdr.ioVRefNum = vRefNum;
  953.    wdr.ioWDIndex = 0;
  954.    wdr.ioWDProcID = 0;
  955.    wdr.ioWDVRefNum = 0;
  956.    PBGetWDInfoSync(&wdr);
  957.    
  958.    spec.vRefNum = wdr.ioWDVRefNum;
  959.    spec.parID = wdr.ioWDDirID;
  960.    PLstrcpy(spec.name, LMGetCurApName());
  961.  
  962.  
  963. +++++++++++++++++++++++++++
  964.  
  965. >From friefeld@deltanet.com (Rob Friefeld)
  966. Date: Sat, 20 Apr 1996 20:46:15 -0800
  967. Organization: Delta Internet Services, Anaheim, CA
  968.  
  969. In article <aevans-1904960935330001@sicola76.sicolamartin.com>,
  970. aevans@sicolamartin.com (Allan Evans) wrote:
  971.  
  972. >In article <bforney-1804962233270001@grimmy.reshall.umich.edu>, Brian
  973. >Forney (bforney@umich.edu) wrote:
  974. >
  975. >> Hi. I'd like to read a file that's in the same directory as my application
  976. >> without using the standard file dialog package. Is there some way to do
  977. >> this? I've looked at the Inside Macintosh File volume, but I haven't found
  978. >> anything that would even hint at this. If there's a FAQ on this, please
  979. >> point me to it.
  980.  
  981. Here is what I use.
  982.  
  983. /*******************************************************************************
  984. //
  985. //    Get the current process file location.
  986. //       On error, vRefNum and dirID contain 0 (default directory)
  987. //
  988. *******************************************************************************/
  989. OSErr WhereAmI(short* vRefNum, long* dirID)
  990. {
  991.    ProcessInfoRec    tempInfo;
  992.    ProcessSerialNumber  PSN;
  993.    FSSpec            procSpec;
  994.    OSErr          err;
  995.  
  996.    PSN.lowLongOfPSN = kCurrentProcess; // First, find out where our app is
  997.    PSN.highLongOfPSN = 0;
  998.  
  999.    tempInfo.processInfoLength = sizeof(ProcessInfoRec);
  1000.    tempInfo.processName = nil;
  1001.    tempInfo.processAppSpec = &procSpec;
  1002.  
  1003.    if ((err = GetProcessInformation(&PSN, &tempInfo)) == noErr) {
  1004.       *vRefNum = procSpec.vRefNum;
  1005.       *dirID = procSpec.parID;
  1006.    }
  1007.    else {
  1008.       *vRefNum = 0;
  1009.       *dirID = 0;
  1010.    }
  1011.    return err;
  1012. }
  1013. -- 
  1014. Rob Friefeld   Long Beach, CA    friefeld@deltanet.com
  1015.  
  1016. +++++++++++++++++++++++++++
  1017.  
  1018. >From mouser@zercom.net (Martin-Gilles Lavoie)
  1019. Date: Tue, 23 Apr 1996 11:04:29 -0500
  1020. Organization: Groupimage, inc.
  1021.  
  1022. In article <bforney-1804962233270001@grimmy.reshall.umich.edu>,
  1023. bforney@umich.edu wrote:
  1024.  
  1025. > Hi. I'd like to read a file that's in the same directory as my application
  1026. > without using the standard file dialog package. Is there some way to do
  1027. > this? I've looked at the Inside Macintosh File volume, but I haven't found
  1028. > anything that would even hint at this. If there's a FAQ on this, please
  1029. > point me to it.
  1030.  
  1031. A quick and dirty way is to call
  1032.  
  1033.     anErr = FSMakeFSSpec(0, 0L, "\p:", &spec);
  1034.  
  1035. early in your application startup.  However, this will not always return
  1036. your application's directory, depending on how the user launched the
  1037. application.
  1038.  
  1039. A better (ie, more complicated) way of getting this information is through
  1040. the Process Manager.  Simply call
  1041.  
  1042.     ProcessInfoRec  info;
  1043.     FSSpec          myAppSpec;
  1044.  
  1045.     info.processAppSpec = &myAppSpec;
  1046.  
  1047.     anErr = GetProcessInformation(kCurrentProcess, &info);
  1048.  
  1049.  
  1050. and find your application's FSSpec in 'myAppSpec'.
  1051.  
  1052. -- 
  1053. Martin-Gilles Lavoie
  1054.  
  1055. [CYRNFR QB ABG ZVK BE BGUREJVFR NYGRE GUR OVGF VA GUVF ZRFFNTR.]
  1056.  
  1057.  
  1058. +++++++++++++++++++++++++++
  1059.  
  1060. >From "Edward Voas" <edv@amargosa.com>
  1061. Date: 25 Apr 96 02:09:13 +0000
  1062. Organization: Shore.Net/Eco Software, Inc; (info@shore.net)
  1063.  
  1064. >Many people recommend using the Process Manager (call FrontProcess() to
  1065. get
  1066. >your Process ID, then call GetProcessInformation(), which returns, among
  1067. >other things, the FSSpec of your application).
  1068. >
  1069.  
  1070. This should really be a GetCurrentProcess call, or just use kCurrentProcess
  1071. in the call to GetProcessInformation. Just in case.
  1072.  
  1073. Ed Voas
  1074.  
  1075. ---------------------------
  1076.  
  1077. >From jimnash@his.com (Jim Nash)
  1078. Subject: How to flush a file.
  1079. Date: Wed, 17 Apr 1996 14:34:53 -0400
  1080. Organization: SRS
  1081.  
  1082. How to flush a file.
  1083.  
  1084. I have critical data that needs to be saved to disk even if there is a
  1085. system crash.  I have used PBFlushFileSync with no luck.  My question is,
  1086. how do you make sure that, after a FSWrite command, data is written to
  1087. disk and that volume information is updated.  When I open the file after a
  1088. simulated crash, the end of file pointer has not been advanced.  Here are
  1089. the details of the test:
  1090.  
  1091. 1.  Open data file.
  1092.  
  1093. 2.  Use FSWrite.
  1094.  
  1095. 3.  Use PBFlushFileSync.
  1096.  
  1097. 4.  Repeat 2 and 3 in a loop and manually turn the computer's power off or
  1098. hit the restart button.
  1099.  
  1100. 5.  Restart the computer and open the data file.
  1101.  
  1102. 6.  Try to read data with FSRead.  End of file = 0.
  1103.  
  1104.  
  1105. The documentation for PBFlushFileSync says that volume information is
  1106. written to the disk.  What is wrong?  How does one *really* flush file
  1107. information?
  1108.  
  1109. I am using System 7.5.1 on a Mac IIfx.
  1110.  
  1111. - Jim
  1112.  
  1113. ____________________________________________________________________
  1114. James W. Nash, Synergistic Research Systems
  1115. 4409 Mahan Court, Silver Spring, MD 20906, USA
  1116. (301) 942-6601, fax: (301) 942-6656
  1117. ____________________________________________________________________
  1118.  
  1119.  
  1120. +++++++++++++++++++++++++++
  1121.  
  1122. >From joviansoft@aol.com (JovianSoft)
  1123. Date: 17 Apr 1996 19:52:50 -0400
  1124. Organization: America Online, Inc. (1-800-827-6364)
  1125.  
  1126. If you're interested in a velveeta answer, you could always OPEN, APPEND,
  1127. AND CLOSE the file in question. That will ensure that it gets written as
  1128. soon as it's called.
  1129.  
  1130. Not particularly speedy, or efficient. Like I said, cheesey.
  1131.  
  1132. HTH
  1133.  
  1134.  
  1135. +++++++++++++++++++++++++++
  1136.  
  1137. >From steve@mindvision.com (Steve Kiene)
  1138. Date: Wed, 17 Apr 1996 20:50:11 -0600
  1139. Organization: MindVision Software
  1140.  
  1141. In article <jimnash-1704961434530001@synergy.his.com>, jimnash@his.com
  1142. (Jim Nash) wrote:
  1143.  
  1144. > How to flush a file.
  1145. > I have critical data that needs to be saved to disk even if there is a
  1146. > system crash.  I have used PBFlushFileSync with no luck.  My question is,
  1147. > how do you make sure that, after a FSWrite command, data is written to
  1148. > disk and that volume information is updated.  When I open the file after a
  1149. > simulated crash, the end of file pointer has not been advanced.  Here are
  1150. > the details of the test:
  1151. > 1.  Open data file.
  1152. > 2.  Use FSWrite.
  1153. > 3.  Use PBFlushFileSync.
  1154. > 4.  Repeat 2 and 3 in a loop and manually turn the computer's power off or
  1155. > hit the restart button.
  1156. > 5.  Restart the computer and open the data file.
  1157. > 6.  Try to read data with FSRead.  End of file = 0.
  1158. > The documentation for PBFlushFileSync says that volume information is
  1159. > written to the disk.  What is wrong?  How does one *really* flush file
  1160. > information?
  1161. > I am using System 7.5.1 on a Mac IIfx.
  1162.  
  1163. Open the file, size it accordingly, call _FlushVol (makes sure the file
  1164. information is written), do your writes with ioPosMode and'ed with 32
  1165. (indicates a request to not cache the write).
  1166.  
  1167. The problem you are having is that the data is being written out, but the
  1168. catalog has not been updated to indicate the file size.
  1169.  
  1170. Steve Kiene
  1171. MindVision Software
  1172.  
  1173. +++++++++++++++++++++++++++
  1174.  
  1175. >From jumplong@aol.com (Jump Long)
  1176. Date: 18 Apr 1996 01:35:26 -0400
  1177. Organization: America Online, Inc. (1-800-827-6364)
  1178.  
  1179. >In article <jimnash-1704961434530001@synergy.his.com>, jimnash@his.com
  1180. >(Jim Nash) wrote:
  1181. >
  1182. >> How to flush a file.
  1183. >> 
  1184. >> I have critical data that needs to be saved to disk even if there is a
  1185. >> system crash.  I have used PBFlushFileSync with no luck.  My question
  1186. is,
  1187. >> how do you make sure that, after a FSWrite command, data is written to
  1188. >> disk and that volume information is updated.  When I open the file
  1189. after a
  1190. >> simulated crash, the end of file pointer has not been advanced.  Here
  1191. are
  1192. >> the details of the test:
  1193. >> 
  1194. >> 1.  Open data file.
  1195. >> 
  1196. >> 2.  Use FSWrite.
  1197. >> 
  1198. >> 3.  Use PBFlushFileSync.
  1199. >> 
  1200. >> 4.  Repeat 2 and 3 in a loop and manually turn the computer's power off
  1201. or
  1202. >> hit the restart button.
  1203. >> 
  1204. >> 5.  Restart the computer and open the data file.
  1205. >> 
  1206. >> 6.  Try to read data with FSRead.  End of file = 0.
  1207. >> 
  1208. >> 
  1209. >> The documentation for PBFlushFileSync says that volume information is
  1210. >> written to the disk.  What is wrong?  How does one *really* flush file
  1211. >> information?
  1212. >> 
  1213. >> I am using System 7.5.1 on a Mac IIfx.
  1214. >
  1215. >Open the file, size it accordingly, call _FlushVol (makes sure the file
  1216. >information is written), do your writes with ioPosMode and'ed with 32
  1217. >(indicates a request to not cache the write).
  1218. >
  1219. >The problem you are having is that the data is being written out, but the
  1220. >catalog has not been updated to indicate the file size.
  1221. >
  1222. >Steve Kiene
  1223. >MindVision Software
  1224.  
  1225. Steve's right. You can read more on this subject in the Macintosh
  1226. Technical Note "FL 16" which covers File Manager performance issues and
  1227. caching issues.
  1228.  
  1229. - Jim Luther
  1230.  
  1231.  
  1232. +++++++++++++++++++++++++++
  1233.  
  1234. >From larson@base.cs.ucla.edu (Christopher Larson)
  1235. Date: 18 Apr 1996 16:17:33 GMT
  1236. Organization: CoBase group, UCLA Department of Computer Science
  1237.  
  1238. In article <jimnash-1704961434530001@synergy.his.com>, jimnash@his.com (Jim Nash) writes:
  1239. > How to flush a file.
  1240. > I have critical data that needs to be saved to disk even if there is a
  1241. > system crash.  I have used PBFlushFileSync with no luck.  My question is,
  1242. > how do you make sure that, after a FSWrite command, data is written to
  1243. > disk and that volume information is updated.  When I open the file after a
  1244. > simulated crash, the end of file pointer has not been advanced.  Here are
  1245. > the details of the test:
  1246. > [ stuff deleted ... ]
  1247.  
  1248. I think the call you need is FlushVol(). Try looking that up or waiting for
  1249. Jim Luther to correct my post :-).
  1250.  
  1251. --Chris
  1252. _______________________________________________________________________________
  1253. Chris Larson -- Amateur Macintosh Geek, CoBase Research Assistant
  1254. L.A. Institute of Slowly and Painfully Working Out the Surprisingly Obvious
  1255. - -------------------------------------+---------------------------------------
  1256. (Insert Disclaimer Here)               | Who's the man ridin' in the sun?
  1257. UCLA Bruins--1995 NCAA Men's Basketball| Who's the man with the itchy gun?
  1258.              National Champions (yea!) | Who's the man who kills for fun?
  1259. Internet: larson@kingston.cs.ucla.edu  | Psycho Dad, Psycho Dad, PSYCHO DAD!
  1260.  
  1261. +++++++++++++++++++++++++++
  1262.  
  1263. >From jumplong@aol.com (Jump Long)
  1264. Date: 20 Apr 1996 12:56:02 -0400
  1265. Organization: America Online, Inc. (1-800-827-6364)
  1266.  
  1267. >In article <jimnash-1704961434530001@synergy.his.com>, jimnash@his.com
  1268. (Jim Nash) writes:
  1269. >> How to flush a file.
  1270. >> 
  1271. >> I have critical data that needs to be saved to disk even if there is a
  1272. >> system crash.  I have used PBFlushFileSync with no luck.  My question
  1273. is,
  1274. >> how do you make sure that, after a FSWrite command, data is written to
  1275. >> disk and that volume information is updated.  When I open the file
  1276. after a
  1277. >> simulated crash, the end of file pointer has not been advanced.  Here
  1278. are
  1279. >> the details of the test:
  1280. >> [ stuff deleted ... ]
  1281. >
  1282. >I think the call you need is FlushVol(). Try looking that up or waiting
  1283. for
  1284. >Jim Luther to correct my post :-).
  1285. >
  1286. >--Chris
  1287.  
  1288. Why would I correct a perfectly good answer? :-}
  1289.  
  1290. - Jim
  1291.  
  1292.  
  1293. +++++++++++++++++++++++++++
  1294.  
  1295. >From tonyn@tiac.net (Tony Nelson)
  1296. Date: Mon, 22 Apr 1996 14:49:13 -0400
  1297. Organization: The Internet Access Company
  1298.  
  1299. In article <steve-1704962050110001@cornholio.mindvision.com>,
  1300. steve@mindvision.com (Steve Kiene) wrote:
  1301.  
  1302. > Open the file, size it accordingly, call _FlushVol (makes sure the file
  1303. > information is written), do your writes with ioPosMode and'ed with 32
  1304. > (indicates a request to not cache the write).
  1305.  
  1306. This will cause physical i/o for each write call.  If you are doing a
  1307. bunch of writes all at once and then need to flush to disk, this will be
  1308. very slow (sort of like MacsBug's LOG command).  A faster way would be to
  1309. flush once at the end; _FlushVol will do the trick.
  1310.  
  1311. > The problem you are having is that the data is being written out, but the
  1312. > catalog has not been updated to indicate the file size.
  1313.  
  1314. Yep.  Just having the data on the disk isn't good enough if the disk
  1315. catalog says it isn't there!
  1316.  
  1317. > Steve Kiene
  1318. > MindVision Software
  1319. ____________________________________________________________________
  1320. TonyN.:'                                              tonyn@tiac.net
  1321.       '
  1322.  
  1323.  
  1324. ---------------------------
  1325.  
  1326. >From deslee@bright.net (Des Courtney)
  1327. Subject: Long Edit Items In Dialogs
  1328. Date: Sun, 21 Apr 1996 04:10:41 -0400
  1329. Organization: Flair Diversions
  1330.  
  1331. I'd like to be able to edit text in Dialogs that can get longer
  1332.   than 255 characters.  Since, for now anyway, there is only one
  1333.   edit field per dialog, I'm thinking about monkeying around with
  1334.   the dialog's "current" TERecord.  Will this work?  Or will I have
  1335.   to resort to coding a User Item?
  1336.  
  1337. Des "Finally Working On Something Again" Courtney
  1338. -- 
  1339. Flair Diversions is... Des Courtney, writer of cool Mac software
  1340.          Outpost Nexus, Ambiance, Icons for MICN, etc.
  1341.    mailto:deslee@bright.net   http://www.bright.net/~deslee/
  1342.       On The Newsgroup Scrapheap: rec.games.video.nintendo
  1343.  
  1344.  
  1345. +++++++++++++++++++++++++++
  1346.  
  1347. >From phaedrus@halcyon.com (Mark Phaedrus)
  1348. Date: Mon, 22 Apr 1996 15:13:49 -0700
  1349. Organization: Lycanthropes Anonymous
  1350.  
  1351. In article <deslee-2104960410410001@find1-cs-6.dial.bright.net>,
  1352. deslee@bright.net (Des Courtney) wrote:
  1353.  
  1354. >I'd like to be able to edit text in Dialogs that can get longer
  1355. >  than 255 characters.  Since, for now anyway, there is only one
  1356. >  edit field per dialog, I'm thinking about monkeying around with
  1357. >  the dialog's "current" TERecord.  Will this work?  Or will I have
  1358. >  to resort to coding a User Item?
  1359.  
  1360.      If all you want to do is get and set the text in edit text items,
  1361. then yes, it can be done.  Here's a stripped-down version of the code I'm
  1362. using to do this, which seems to be working just fine:
  1363.  
  1364. OSErr GetDString(const DialogPtr theDialog, const short ID, char * buf)
  1365. {
  1366.     Handle htext;
  1367.     short theType;
  1368.     Rect myRect;
  1369.     Size textsize;
  1370.  
  1371.     /* Get the item's info, including its TextEdit handle */
  1372.     GetDItem(theDialog,ID,&theType,&htext,&myRect);
  1373.     /* Sanity check here; make sure we're dealing with an editText item */
  1374.     theType = theType & ~itemDisable;
  1375.     if (theType != editText) {
  1376.         return(paramErr);
  1377.     }
  1378.     /* Find out how big the text is... */
  1379.     textsize = GetHandleSize(htext);
  1380.     /* ... and copy it into the buffer (overflow checking deleted as usual
  1381.        for sample code) */
  1382.     if (textSize) {
  1383.         BlockMove(*hText,buf,textsize);
  1384.     }
  1385.     buf[textSize] = '\0';
  1386.     return(noErr);
  1387. }
  1388.  
  1389. OSErr SetDString(const DialogPtr theDialog, const short ID, const char * buf)
  1390. {
  1391.     Handle htext;
  1392.     short theType;
  1393.     Rect myRect;
  1394.     OSErr err = noErr;
  1395.     GrafPtr port;
  1396.  
  1397.     GetPort(&port);
  1398.     SetPort(theDialog);
  1399.     GetDItem(theDialog,ID,&theType,&htext,&myRect);
  1400.     /* sanity check deleted from this one */
  1401.     /* Set the insertion point in the target item; this makes sure that it's
  1402.        the current item, which makes the Dialog Manager set it up
  1403.        properly */
  1404.     SelIText(theDialog,ID,0,0);
  1405.     /* Copy the text into the Dialog Manager's TextEdit handle */
  1406.     TESetText(buf,strlen(buf),((DialogPeek)theDialog)->textH);
  1407.     /* TextEdit and the Dialog Manager won't trigger a redraw when you do
  1408.        this; you've gotta do it yourself--fortunately we have the item's
  1409.        rectangle handy */
  1410.     InvalRect(&myRect);
  1411.     /* Set the selection point again (this one happens to set it to the end
  1412.        of the text); this forces the Dialog Manager to recognize the changes
  1413.        you've made to the TextEdit handle */
  1414.     SelIText(theDialog,ID,32767,32767);
  1415.     return(noErr);
  1416. }
  1417.  
  1418.      I hope this helps...
  1419.  
  1420. -- 
  1421. \o\ If you're interested in books/stories with transformation themes,\o\
  1422.  \o\please try <URL:http://www.halcyon.com/phaedrus/Menu.html>, or    \o\
  1423.  /o/anonymous-ftp to ftp.halcyon.com in /local/phaedrus/translist.    /o/
  1424. /o/ Comments and submissions to this list are always welcome.        /o/
  1425.  
  1426. +++++++++++++++++++++++++++
  1427.  
  1428. >From deslee@bright.net (Des Courtney)
  1429. Date: Wed, 24 Apr 1996 03:49:33 -0400
  1430. Organization: Flair Diversions
  1431.  
  1432. In article <phaedrus-2204961513490001@blv-pm13-ip20.halcyon.com>,
  1433.   phaedrus@halcyon.com (Mark Phaedrus) wrote:
  1434.  
  1435. )      If all you want to do is get and set the text in edit text items,
  1436. ) then yes, it can be done.  Here's a stripped-down version of the code I'm
  1437. ) using to do this, which seems to be working just fine:
  1438. [code saved]
  1439.  
  1440. Cool!  Thanks, I'll try it out next chance I get.
  1441.  
  1442. Des Courtney
  1443. -- 
  1444. Flair Diversions is... Des Courtney, writer of cool Mac software
  1445.          Outpost Nexus, Ambiance, Icons for MICN, etc.
  1446.    mailto:deslee@bright.net   http://www.bright.net/~deslee/
  1447.          On The Newsgroup Scrapheap: rec.arts.tv.mst3k
  1448.  
  1449. +++++++++++++++++++++++++++
  1450.  
  1451. >From SouthSide@kagi.com (Bob Bradley)
  1452. Date: 24 Apr 96 16:48:22 GMT
  1453. Organization: Applied BioSystems
  1454.  
  1455. In article <deslee-2104960410410001@find1-cs-6.dial.bright.net>,
  1456. deslee@bright.net (Des Courtney) wrote:
  1457.  
  1458. >I'd like to be able to edit text in Dialogs that can get longer
  1459. >  than 255 characters.  Since, for now anyway, there is only one
  1460. >  edit field per dialog, I'm thinking about monkeying around with
  1461. >  the dialog's "current" TERecord.  Will this work?  Or will I have
  1462. >  to resort to coding a User Item?
  1463.  
  1464. I think the only 255 character limit on editText items is in using
  1465. Get/SetDialogItem cause they only accept a Str255. Messing with the
  1466. TERecord directly should work. Just remember the TERecord is for all the
  1467. editText items in the dialog.
  1468.  
  1469. The problem is that even if this does work, it would seem that anything in
  1470. a dialog using more than 255 characters might need a scrollbar which would
  1471. be difficult to implement using the Dialog Manager's text handling.
  1472.  
  1473. You'd probably end up spending more time messing with the Dialog Manager
  1474. to get it working then you would to just create a user item in the dialog
  1475. and create your own TERecord.
  1476.  
  1477. +++++++++++++++++++++++++++
  1478.  
  1479. >From jwbaxter@olympus.net (John W. Baxter)
  1480. Date: Wed, 24 Apr 1996 18:50:35 -0700
  1481. Organization: Internet for the Olympic Peninsula
  1482.  
  1483. In article <SouthSide-2404960950010001@192.43.251.123>, SouthSide@kagi.com
  1484. (Bob Bradley) wrote:
  1485.  
  1486. >In article <deslee-2104960410410001@find1-cs-6.dial.bright.net>,
  1487. >deslee@bright.net (Des Courtney) wrote:
  1488. >
  1489. >>I'd like to be able to edit text in Dialogs that can get longer
  1490. >>  than 255 characters.  Since, for now anyway, there is only one
  1491. >>  edit field per dialog, I'm thinking about monkeying around with
  1492. >>  the dialog's "current" TERecord.  Will this work?  Or will I have
  1493. >>  to resort to coding a User Item?
  1494. >
  1495. >I think the only 255 character limit on editText items is in using
  1496. >Get/SetDialogItem cause they only accept a Str255. Messing with the
  1497. >TERecord directly should work. Just remember the TERecord is for all the
  1498. >editText items in the dialog.
  1499. >
  1500. >The problem is that even if this does work, it would seem that anything in
  1501. >a dialog using more than 255 characters might need a scrollbar which would
  1502. >be difficult to implement using the Dialog Manager's text handling.
  1503. >
  1504. >You'd probably end up spending more time messing with the Dialog Manager
  1505. >to get it working then you would to just create a user item in the dialog
  1506. >and create your own TERecord.
  1507.  
  1508. One of the suggestions in Inside Mac boils down to:  if implementing a
  1509. dialog as a Dialog starts getting difficult, don't.  Use a real window
  1510. (built to look like a Dialog).  It's easier to deal with the events the
  1511. normal way than to deal with the Dialog Manager's "help".  See pages 6-16
  1512. and 6-17 in Inside Mac:  Macintosh Toolbox Essentials for some help in
  1513. deciding.
  1514.  
  1515. MacApp does almost all dialogs itself (StandardFile is an exception, as it
  1516. should be).  Even the simplest (it tends to do alerts using the Dialog
  1517. Manager, last I looked.  This is a source of annoyance to QuicKeys
  1518. (spelled wrong here) users.
  1519.  
  1520.    --John
  1521.  
  1522. -- 
  1523.   The primary cause of problems is solutions.
  1524. John W. Baxter    Port Ludlow, WA, USA     jwbaxter@olympus.net
  1525.  
  1526. ---------------------------
  1527.  
  1528. >From Manabu Tokanaga <manabu@aimnet.com>
  1529. Subject: MacOS Queue Utilities sample code
  1530. Date: Fri, 26 Apr 1996 15:36:02 -0700
  1531. Organization: Aimnet Information Services
  1532.  
  1533. I would like to get some sample code in C or C++ illustrating how
  1534. to use the Queue Utility routines to handle MacOS queues.  Does
  1535. anyone have some they could send to me or know where I can get
  1536. some code examples?  I would appreciate hearing from anyone who
  1537. could help.  Thanks very much in advance...
  1538.  
  1539. Vic Hargrave
  1540. vich@acuson.com
  1541. Cyberspace, the final frontier.
  1542.  
  1543.  
  1544. +++++++++++++++++++++++++++
  1545.  
  1546. >From bzuk@telerama.lm.com (Brian Zuk)
  1547. Date: Fri, 26 Apr 1996 20:57:47 -0400
  1548. Organization: Telerama Public Access Internet, Pittsburgh, PA
  1549.  
  1550. In article <31814FD2.609B@acuson.com>, Manabu Tokanaga <manabu@aimnet.com>
  1551. wrote:
  1552.  
  1553. >I would like to get some sample code in C or C++ illustrating how
  1554. >to use the Queue Utility routines to handle MacOS queues.  Does
  1555. >anyone have some they could send to me or know where I can get
  1556. >some code examples?  I would appreciate hearing from anyone who
  1557. >could help.  Thanks very much in advance...
  1558. >
  1559. >Vic Hargrave
  1560. >vich@acuson.com
  1561. >Cyberspace, the final frontier.
  1562.  
  1563. Vic,
  1564.   I think I am answering the question you are asking.  Here goes...
  1565.  
  1566. QHdr    queue = { 0, NULL, NULL };
  1567.  
  1568. struct MyQueueElem
  1569. {
  1570.  MyQueueElem*     qLink;
  1571.  SInt16           qType;
  1572.  .... add what ever data you want to here
  1573. } ;
  1574.  
  1575. MyQueueElem*    qElem;
  1576.  
  1577. qElem = NewPtrClear(sizeof(MyQueueElem); // MUST use new or NewPtr
  1578. Enqueue((QElemPtr)qElem, &queue); // I may have these parameters reversed
  1579. ...
  1580. MyQueueElem*    link = queue.qHead;
  1581.  
  1582. while(link != NULL)
  1583. {
  1584.  ...
  1585.  link = link->qLink;
  1586. }
  1587. ...
  1588. Dequeue((QElemPtr)qElem, &queue);
  1589. DisposePtr((Ptr)qElem);
  1590.  
  1591. Brian Zuk
  1592.  
  1593. ---------------------------
  1594.  
  1595. >From Nathaniel P Woods <nw2d+@andrew.cmu.edu>
  1596. Subject: MacTCP Q: Finding the local host's IP address
  1597. Date: Fri, 19 Apr 1996 13:15:52 -0400
  1598. Organization: Sophomore, Electrical and Computer Engineering, Carnegie Mellon, Pittsburgh, PA
  1599.  
  1600. What MacTCP call allows a program to obtain the current host's IP address?
  1601.  
  1602. Thanks in advance,
  1603. Nathaniel
  1604.  
  1605. +++++++++++++++++++++++++++
  1606.  
  1607. >From markus-1.maier@student.uni-ulm.de (Markus Maier)
  1608. Date: Sun, 21 Apr 1996 18:24:42 +0200
  1609. Organization: University Of Ulm
  1610.  
  1611. In article <slRwd8K00iWSE6BVtO@andrew.cmu.edu>,
  1612. Nathaniel P Woods <nw2d+@andrew.cmu.edu> wrote:
  1613.  
  1614. > What MacTCP call allows a program to obtain the current host's IP address?
  1615. > Thanks in advance,
  1616. > Nathaniel
  1617.  
  1618. The following code will do the job:
  1619. OSErr GetMyIPAddr(ip_addr *inAddr)
  1620. {
  1621.     struct GetAddrParamBlock    ipBlock;
  1622.     OSErr                        anErr;
  1623.     
  1624.     ipBlock.csCode = ipctlGetAddr;
  1625.     ipBlock.ioCRefNum = mMacTCPRefNum;
  1626.     
  1627.     anErr = PBControlSync((ParmBlkPtr)&ipBlock);
  1628.     *inAddr = ipBlock.ourAddress;
  1629.  
  1630.     return anErr;
  1631. }
  1632.  
  1633.  
  1634. Markus
  1635.  
  1636.  
  1637.  
  1638.  
  1639. ---------------------------
  1640.  
  1641. >From yan@darwin.bu.edu (Y. Tony Lee)
  1642. Subject: New Mac Programming Web Page
  1643. Date: Sun, 21 Apr 1996 23:46:54 -0500
  1644. Organization: Boston University
  1645.  
  1646. Hello,
  1647.    I have constructed a web site filled with links related to Mac
  1648. programming.  The URL is:
  1649. http://med-amsa.bu.edu/Pharmacology/pharm.people/Lee/MacProg.html
  1650.  
  1651. I hope the page helps all Mac Programmers.
  1652.  
  1653. Tony
  1654.  
  1655. -- 
  1656. Home Page:
  1657. http://med-amsa.bu.edu/Pharmacology/pharm.people/Lee/Lee.html
  1658. Mac Developer Central:
  1659. http://med-amsa.bu.edu/Pharmacology/pharm.people/Lee/MacProg.html
  1660.  
  1661. ---------------------------
  1662.  
  1663. >From KTrueman@ixmedia.com (Kenneth Trueman)
  1664. Subject: QuickDraw GX : Developer info at the GX Fan Club
  1665. Date: Sun, 21 Apr 1996 22:55:42 -0400
  1666. Organization: QuickDraw GX Fan Club
  1667.  
  1668. In the last few months, I have dedicated a section of the GX Fan Club web
  1669. site to developer information about QuickDraw GX.  There you will find
  1670. links to GX-speicifc web resources, develop articles, Apple DTS technotes,
  1671. Tech Q & As, and more. 
  1672.  
  1673. There is a subscription form if you would like to come join the more than
  1674. 160 members of the GX developers mailing list.   The archives of the
  1675. GXLists are now searchable via the Web too ...
  1676.  
  1677. I have also set up a page dedicated to GX and the upcoming WWDC ... come
  1678. see who's going to WWDC this year ...
  1679.  
  1680. http://www.ixmedia.com/quickgx/gxdev.html
  1681.  
  1682. doing what I can to help out GX ...
  1683.  
  1684. Kenneth
  1685. glad to be back on UseNet ... thanks Geoff ...
  1686.  
  1687. -- 
  1688. ktrueman@ixmedia.com
  1689. Hungry for GX info ? Check out the QuickDraw GX Fan Club pages :
  1690. <http://www.ixmedia.com/quickgx/quickgx.html>
  1691. For more info on the QuickDraw GX Fan Club, send a message to gxfanclub@ixmedia.com
  1692.  
  1693. ---------------------------
  1694.  
  1695. >From ckilpatrick@wesleyan.edu (Charlie Kilpatrick)
  1696. Subject: QuickTime Music Architecture -- Long Delays in Playing Notes
  1697. Date: Tue, 23 Apr 1996 16:01:57 -0400
  1698. Organization: Wesleyan University
  1699.  
  1700. We have been experiencing problems using QuickTime Music Architecture on
  1701. PowerPCs.  There can be increasingly long delays between the time QTMA is
  1702. told to generate a note, and when the note is actually heard.
  1703.  
  1704. Problem Description:
  1705.    To test out this problem, we have been running an application called
  1706. "Instrument Picker", an application provided on Apple's Developer CD
  1707. Series.  This application lets you select an instrument and click on an
  1708. onscreen keyboard to generate notes.  When this application is first
  1709. opened, there is no delay whatsoever between clicking on the keyboard and
  1710. hearing the note.  As time progresses, a delay time between clicking &
  1711. hearing steadily increases.  The rate seems to be about 2 seconds of delay
  1712. for every 3-4 minutes that the application is open.  Quiting the
  1713. application and reopening it will make the delay time between clicking &
  1714. hearing notes reset to zero, only to increase again.  This delay is
  1715. critically unacceptable because we are developing an application that
  1716. sends UDP messages to computers across a network to have them play in
  1717. sync.
  1718.  
  1719.    What is puzzling about this problem is that only exists on certain
  1720. computers, unpredictibly -- we have experienced it mainly on 7100/80's
  1721. running either 7.5.1 or 7.5.3.  7100/66's are safer, and a Quadra does not
  1722. exhibit the problem.  The relevant extensions we have loaded are QuickTime
  1723. 2.1, QuickTime™ Musical Instruments 2.1, Sound Manager 3.1, QuickTime
  1724. PowerPlug.
  1725.  
  1726.    We would be extremely grateful for any help or to hear from anyone who
  1727. has experienced similar problems to help us narrow down the particular
  1728. extension or whatnot that is causing this problem.
  1729.  
  1730. --
  1731. Charlie Kilpatrick
  1732. ckilpatrick@wesleyan.edu
  1733.  
  1734. +++++++++++++++++++++++++++
  1735.  
  1736. >From reekes@apple.com (Jim Reekes)
  1737. Date: Thu, 25 Apr 1996 13:32:10 -0700
  1738. Organization: Apple Computer, Inc.
  1739.  
  1740. In article <ckilpatrick-2304961601570001@ckilpatrick.stu.wesleyan.edu>,
  1741. ckilpatrick@wesleyan.edu (Charlie Kilpatrick) wrote:
  1742.  
  1743. > We have been experiencing problems using QuickTime Music Architecture on
  1744. > PowerPCs.  There can be increasingly long delays between the time QTMA is
  1745. > told to generate a note, and when the note is actually heard.
  1746.  
  1747. Yes, this is true. It's been fixed in the next release of QuickTime.
  1748.  
  1749. -- 
  1750. Jim Reekes, Polterzeitgeist |       QuickTime Products R&D
  1751.                             |        Sound Manager Expert
  1752. Apple Computer, Inc.        | "All opinions expressed are mine, and
  1753. 2 Infinite Loop  MS 302-3KS |  do not necessarily represent those
  1754. Cupertino, CA 95014         |  of my employer, Apple Computer Inc."
  1755.  
  1756.  
  1757. ---------------------------
  1758.  
  1759. >From DaveZ@mailbag.com (David B. Zwiefelhofer)
  1760. Subject: Temporary Heaps
  1761. Date: Thu, 11 Apr 1996 19:18:36 -0500
  1762. Organization: Utility Reduction Specialists, Inc.
  1763.  
  1764. I have a faceless background application that needs to be running all the
  1765. time. I want it to take up very little RAM while it is not actively doing
  1766. it's thing. Unfortunately, it's thing requires anywhere from 150K to  1.5M
  1767. so I'd like to have it do it's thing in a temporary, disposable heap. I
  1768. know nothing of how this is done.
  1769.  
  1770. Can someone please give me a general run down on how to:
  1771.  
  1772. 1) Allocate the heap.
  1773.  
  1774. 2) Make GWorlds and allocate other toolbox structures in the new heap.
  1775.  
  1776. 3) Anything else relevant to using temporary heaps.
  1777.  
  1778.  
  1779. Thanks much,
  1780.  
  1781. Dave
  1782.  
  1783. -- 
  1784. David B. Zwiefelhofer
  1785. Utility Reduction Specialists, Inc.
  1786. 1605 Monroe Street, Suite 110
  1787. Madison, WI  53211-2052
  1788. (608) 258-8965
  1789. (608) 258-9686 FAX
  1790.  
  1791. +++++++++++++++++++++++++++
  1792.  
  1793. >From mhteas@btech.com (Malcolm H. Teas)
  1794. Date: 17 Apr 1996 13:08:42 GMT
  1795. Organization: Blaze Technology, Inc.
  1796.  
  1797. In article <DaveZ-1604960803590001@msn_7_2.binc.net>
  1798. DaveZ@mailbag.com (David B. Zwiefelhofer) writes:
  1799.  
  1800. > > Once your temp. block is there, use SetZone() to designate it as the
  1801. > > current heap zone.  Call GetZone() before hand to get your current app
  1802. > > zone first, so you can restore things later.
  1803. > > 
  1804. > Actually, I've learned that you need to call InitZone first, then SetZone.
  1805.  
  1806. Uh, sorry.  Good point, I forgot that.
  1807.  
  1808. > I do use the temporary memory for much longer than one loop, but I do
  1809. > unlock it before each call to WaitNextEvent.
  1810.  
  1811. As you're using temp. memory to allocate a temporary heap, you *don't*
  1812. want to unlock it!  Heaps have pointers in them.  If your temp. heap
  1813. floats, those pointers will be bad & your program will crash.  Just
  1814. allocate it, move it high, and lock it down till you're done with it
  1815. and ready to deallocate it.
  1816.  
  1817. Glad to hear it's going well.
  1818.  
  1819. Malcolm  H. Teas                E-Mail: mhteas@btech.com
  1820. Blaze Technology, Inc.          Telephone: 512/502-9552
  1821. PO Box 200279                   Fax: 512/502-9554
  1822. Austin, TX USA 78720-0279       WWW: http://www.btech.com/
  1823.    ** A Macintosh software development services company  **
  1824.  
  1825. +++++++++++++++++++++++++++
  1826.  
  1827. >From squires@crl.com (Scott Squires)
  1828. Date: Wed, 17 Apr 1996 07:51:54 -0800
  1829. Organization: Puffin Designs
  1830.  
  1831. In article <DaveZ-1604960803590001@msn_7_2.binc.net>,
  1832. DaveZ@mailbag.com (David B. Zwiefelhofer) wrote:
  1833.  
  1834.  >I would use just TempNewHandle if I could, but I need to call routines
  1835. >such as NewGWorld that are allocated in the current heap, so I don't have
  1836. >much choice.
  1837. >
  1838.  
  1839.  
  1840. Just pass 'useTempMem' as a GWorldFlag to NewGWorld.
  1841.  
  1842.  
  1843. -scott
  1844.  
  1845.  
  1846. Scott Squires               "Insert funny stuff here"
  1847. squires@crl.com
  1848. ScottSquir@aol.com
  1849.  
  1850.  
  1851.  
  1852. +++++++++++++++++++++++++++
  1853.  
  1854. >From andrewwelc@aol.com (AndrewWelc)
  1855. Date: 17 Apr 1996 11:30:29 -0400
  1856. Organization: America Online, Inc. (1-800-827-6364)
  1857.  
  1858. > As you're using temp. memory to allocate a temporary heap, you *don't*
  1859. > want to unlock it!  Heaps have pointers in them.  If your temp. heap
  1860. > floats, those pointers will be bad & your program will crash.  Just
  1861. > allocate it, move it high, and lock it down till you're done with it and
  1862. > ready to deallocate it.
  1863.  
  1864. This is exactly what I did in a project I worked on recently... and it
  1865. crashed/froze on certain machines.  To recap:  I allocated a temporary
  1866. block of memory, locked it down, and then called InitZone() on it.  I was
  1867. careful about preserving the proper heap zone, etc.
  1868.  
  1869. To this day, I can't figure out what was going wrong.
  1870.  
  1871. +--------------------------------------------------------------+
  1872. |    Andrew Welch - Thaumaturgist - Ambrosia Software, Inc.    |
  1873. +-------------------------------+------------------------------+
  1874. |    AOL-> Keyword: Ambrosia    |  http://www.AmbrosiaSW.com/  |
  1875. |    CIS-> GO word: Ambrosia    |   ftp://ftp.AmbrosiaSW.com/  |
  1876. +-------------------------------+------------------------------+
  1877.  
  1878.  
  1879. +++++++++++++++++++++++++++
  1880.  
  1881. >From pottier@drakkar.ens.fr (Francois Pottier)
  1882. Date: 18 Apr 1996 09:45:29 GMT
  1883. Organization: Ecole Normale Superieure, Paris
  1884.  
  1885. In article <DaveZ-1104961918360001@msn_3_16.binc.net>,
  1886. David B. Zwiefelhofer <DaveZ@mailbag.com> wrote:
  1887.  
  1888. >3) Anything else relevant to using temporary heaps.
  1889.  
  1890. - Try to avoid it. Although there are Memory Manager functions
  1891.   to do it, it is discouraged by Apple. A previous version of
  1892.   one of my programs used to create a heap inside a temporary
  1893.   block and work in there. This caused no end of compatibility
  1894.   problems with Virtual Memory, RAM Doubler and various functions
  1895.   like RecoverHandle() which didn't behave correctly. My current solution
  1896.   is to allocate large blocks in the temporary heap (for instance, by
  1897.   passing the useTempMem flag to NewGWorld) and small blocks in the
  1898.   application heap, and conflicts have disappeared.
  1899.  
  1900. - If you must do it, be aware that there is a new, undocumented
  1901.   function in the Modern Memory Manager called DisposeZone. I think
  1902.   you should call it when you destroy your private zone. This is
  1903.   because the MMM keeps a list of all existing zones for use by
  1904.   RecoverHandle() and the list will become corrupted if you don't
  1905.   call it.
  1906.  
  1907. Hope this helps,
  1908.  
  1909. -- 
  1910. Francois Pottier
  1911. Francois.Pottier@ens.fr
  1912. Francois.Pottier@inria.fr
  1913. http://www.eleves.ens.fr:8080/home/pottier/
  1914.  
  1915. +++++++++++++++++++++++++++
  1916.  
  1917. >From jeff@purple.com (Jeff Abrahamson)
  1918. Date: Thu, 18 Apr 1996 10:47:12 -0400
  1919. Organization: PDI
  1920.  
  1921. In article <4l52vp$bj0@nef.ens.fr>, pottier@drakkar.ens.fr (Francois
  1922. Pottier) wrote:
  1923.  
  1924. > In article <DaveZ-1104961918360001@msn_3_16.binc.net>,
  1925. > David B. Zwiefelhofer <DaveZ@mailbag.com> wrote:
  1926. > >3) Anything else relevant to using temporary heaps.
  1927. > - Try to avoid it. Although there are Memory Manager functions
  1928. >   to do it, it is discouraged by Apple. A previous version of
  1929. > [snip]
  1930.  
  1931. Just to be clear, is the issue as follows:
  1932.  
  1933.    1. Temporary *heaps* are discouraged.
  1934.  
  1935.    2. Allocating blocks of temporary memory (multi-finder memory) is ok.
  1936.  
  1937. +++++++++++++++++++++++++++
  1938.  
  1939. >From larson@base.cs.ucla.edu (Christopher Larson)
  1940. Date: 18 Apr 1996 16:15:29 GMT
  1941. Organization: CoBase group, UCLA Department of Computer Science
  1942.  
  1943. In article <4l32ql$4h9@newsbf02.news.aol.com>, andrewwelc@aol.com (AndrewWelc) writes:
  1944. > > As you're using temp. memory to allocate a temporary heap, you *don't*
  1945. > > want to unlock it!  Heaps have pointers in them.  If your temp. heap
  1946. > > floats, those pointers will be bad & your program will crash.  Just
  1947. > > allocate it, move it high, and lock it down till you're done with it and
  1948. > > ready to deallocate it.
  1949. > This is exactly what I did in a project I worked on recently... and it
  1950. > crashed/froze on certain machines.  To recap:  I allocated a temporary
  1951. > block of memory, locked it down, and then called InitZone() on it.  I was
  1952. > careful about preserving the proper heap zone, etc.
  1953. > To this day, I can't figure out what was going wrong.
  1954.  
  1955. If it was crashing while you were disposing of the temporary heap zone
  1956. (or exiting your program) you were probably bitten by the MMM. There is
  1957. a dispose call, the counterpart of InitZone(), which you need to call
  1958. when disposing of a heap zone. (If memory serves, it's called DisposeZone().)
  1959.  
  1960. The only place I have seen this 'documented' was in the Kon & Bal column
  1961. of _Develop_ a couple of issues ago (I'm away from my Mac at the moment,
  1962. so I can't look it up for you, :-( but it's there somewhere.) The gist of
  1963. it was that _most_ of the time the MMM can figure out when a block is a
  1964. heap zone, but not always. You might try giving that a look or appealing
  1965. to a higher authority.
  1966.  
  1967. --Chris
  1968. _______________________________________________________________________________
  1969. Chris Larson -- Amateur Macintosh Geek, CoBase Research Assistant
  1970. L.A. Institute of Slowly and Painfully Working Out the Surprisingly Obvious
  1971. - -------------------------------------+---------------------------------------
  1972. (Insert Disclaimer Here)               | Who's the man ridin' in the sun?
  1973. UCLA Bruins--1995 NCAA Men's Basketball| Who's the man with the itchy gun?
  1974.              National Champions (yea!) | Who's the man who kills for fun?
  1975. Internet: larson@kingston.cs.ucla.edu  | Psycho Dad, Psycho Dad, PSYCHO DAD!
  1976.  
  1977. +++++++++++++++++++++++++++
  1978.  
  1979. >From andrewwelc@aol.com (AndrewWelc)
  1980. Date: 18 Apr 1996 13:19:01 -0400
  1981. Organization: America Online, Inc. (1-800-827-6364)
  1982.  
  1983. > If it was crashing while you were disposing of the temporary heap zone
  1984. > (or exiting your program) you were probably bitten by the MMM. There is
  1985. a
  1986. > dispose call, the counterpart of InitZone(), which you need to call when
  1987. > disposing of a heap zone. (If memory serves, it's called DisposeZone().)
  1988.  
  1989. That sounds like something which makes sense.  Ugh.  Undocumented, eh?  I
  1990. think I know why it may not have been able to figure out that those blocks
  1991. were heap zones.  I padded the heap block a tad... may have confused the
  1992. MMM.
  1993.  
  1994. What do your calls to InitZone() look like?
  1995.  
  1996.  
  1997. +--------------------------------------------------------------+
  1998. |    Andrew Welch - Thaumaturgist - Ambrosia Software, Inc.    |
  1999. +-------------------------------+------------------------------+
  2000. |    AOL-> Keyword: Ambrosia    |  http://www.AmbrosiaSW.com/  |
  2001. |    CIS-> GO word: Ambrosia    |   ftp://ftp.AmbrosiaSW.com/  |
  2002. +-------------------------------+------------------------------+
  2003.  
  2004. +++++++++++++++++++++++++++
  2005.  
  2006. >From pottier@drakkar.ens.fr (Francois Pottier)
  2007. Date: 19 Apr 1996 07:48:12 GMT
  2008. Organization: Ecole Normale Superieure, Paris
  2009.  
  2010. In article <jeff-1804961047120001@news.digex.net>,
  2011. Jeff Abrahamson <jeff@purple.com> wrote:
  2012. >Just to be clear, is the issue as follows:
  2013. >
  2014. >   1. Temporary *heaps* are discouraged.
  2015. >
  2016. >   2. Allocating blocks of temporary memory (multi-finder memory) is ok.
  2017.  
  2018. That's what I meant. I seem to recall hearing an Apple engineer
  2019. warning against private heaps in this newsgroup, and indeed my
  2020. practical experience has told me they caused compatibility
  2021. problems. Temporary blocks, on the other hand, are entirely OK. It's
  2022. even OK to keep them locked, even though everybody will warn you
  2023. against it ;-) (I know, I know, I shouldn't)
  2024.  
  2025. -- 
  2026. Francois Pottier
  2027. Francois.Pottier@ens.fr
  2028. Francois.Pottier@inria.fr
  2029. http://www.eleves.ens.fr:8080/home/pottier/
  2030.  
  2031. +++++++++++++++++++++++++++
  2032.  
  2033. >From dpi@pobox.oleane.com (Vincent Nonnenmacher)
  2034. Date: Fri, 19 Apr 1996 18:22:21 +0200
  2035. Organization: DPI
  2036.  
  2037. In article <4l32ql$4h9@newsbf02.news.aol.com>,
  2038. andrewwelc@aol.com (AndrewWelc) wrote:
  2039.  
  2040. >> As you're using temp. memory to allocate a temporary heap, you *don't*
  2041. >> want to unlock it!  Heaps have pointers in them.  If your temp. heap
  2042. >> floats, those pointers will be bad & your program will crash.  Just
  2043. >> allocate it, move it high, and lock it down till you're done with it and
  2044. >> ready to deallocate it.
  2045. >
  2046. >This is exactly what I did in a project I worked on recently... and it
  2047. >crashed/froze on certain machines.  To recap:  I allocated a temporary
  2048. >block of memory, locked it down, and then called InitZone() on it.  I was
  2049. >careful about preserving the proper heap zone, etc.
  2050. >
  2051. >To this day, I can't figure out what was going wrong.
  2052. >
  2053.  
  2054. I had exactly the same trouble, I haven't figured out either was
  2055. was wromg the program runs fine witout the new memory manager.
  2056.  
  2057. I tested under QC, validating everything and I haven't found anything
  2058. bad or any word from Apple to 'discourage' people doint this !
  2059.  
  2060. They just said it is improper to make assumption about the document
  2061. Heapzone header just that, and anyway this header is initialized
  2062. by the InitZone call.
  2063.  
  2064. So Mr Apple if ewMemory manager is not supporting new heaps or
  2065. Heaps inside heaps please let us know !!!!!!!!
  2066.  
  2067. Vincent Nonnenmacher
  2068.  
  2069.  
  2070. Vincent Nonnenmacher
  2071.  
  2072. DPI SA
  2073. 116 AV DE LA REPUBLIQUE
  2074. 38320 BRESSON
  2075. (33) 76 33 25 06    fax (33) 76 33 25 01
  2076.  
  2077. +++++++++++++++++++++++++++
  2078.  
  2079. >From Andrew Welch <andrew@AmbrosiaSW.com>
  2080. Date: Fri, 19 Apr 1996 17:40:33 -0500
  2081. Organization: Ambrosia Software, Inc.
  2082.  
  2083. Christopher Larson wrote:
  2084.  
  2085. > If it was crashing while you were disposing of the temporary heap zone
  2086. > (or exiting your program) you were probably bitten by the MMM. There is
  2087. > a dispose call, the counterpart of InitZone(), which you need to call
  2088. > when disposing of a heap zone. (If memory serves, it's called DisposeZone().)
  2089.  
  2090. Here's the code I was using... if anyone sees something wrong with it, I'd love to hear 
  2091. it...
  2092.  
  2093. // -------------------------------------------------------------------------------
  2094. // -- Create a heap zone in temporary memory
  2095.  
  2096. THz CreateTempHeapZone(long zoneSize)
  2097. {
  2098. Handle    tempHandle;
  2099. THz        result;
  2100. OSErr    err;
  2101.  
  2102. tempHandle = TempNewHandle(zoneSize, &err);
  2103. if ((tempHandle) && (err == noErr))
  2104.     {
  2105.     HLock(tempHandle);
  2106.     if (MemError() == noErr)
  2107.         {
  2108.         Ptr        limit, start;
  2109.         short    index;
  2110.         THz        oldZone;
  2111.         
  2112. // -- Initialize the heap zone
  2113.  
  2114.         result = (THz)(*tempHandle);
  2115.         start = StripAddress((Ptr)(*tempHandle));
  2116.         limit = start + zoneSize - 4;
  2117.                 
  2118.         oldZone = GetZone();
  2119.         InitZone(nil, 32, limit, start);
  2120.         SetZone(result);
  2121.  
  2122.         for (index = 0; index < NUM_HEAP_MASTERS; index++)
  2123.             MoreMasters();
  2124.         SetZone(oldZone);
  2125.         }
  2126.     }
  2127.  
  2128. return result;
  2129. }    // -- CreateTempHeapZone
  2130.  
  2131.  
  2132. // -------------------------------------------------------------------------------
  2133. // -- Dispose a heap zone in temporary memory
  2134.  
  2135. void DisposeTempHeapZone(THz theZone)
  2136. {
  2137. Handle    tempHandle;
  2138.  
  2139. tempHandle = RecoverHandle((Ptr)theZone);
  2140. if (tempHandle)
  2141.     {
  2142.     DisposeHandle(tempHandle);
  2143.     }
  2144. }    // -- DisposeTempHeapZone
  2145.  
  2146.  
  2147. +--------------------------------------------------------------+
  2148. |    Andrew Welch - Thaumaturgist - Ambrosia Software, Inc.    |
  2149. +-------------------------------+------------------------------+
  2150. |    AOL-> Keyword: Ambrosia    |  http://www.AmbrosiaSW.com/  |
  2151. |    CIS-> GO word: Ambrosia    |   ftp://ftp.AmbrosiaSW.com/  |
  2152. +-------------------------------+------------------------------+
  2153.  
  2154.  
  2155. +++++++++++++++++++++++++++
  2156.  
  2157. >From dwarker@acy.digex.net (Dave Warker)
  2158. Date: Sat, 20 Apr 1996 11:59:17 -0400
  2159. Organization: Express Access Online Communications, USA
  2160.  
  2161. If you dig back in the develop issues, I believe there was a discussion
  2162. in, of all places, the Puzzle Page (and some folks say it doesn't teach
  2163. anything) about the problems with temporary heaps. It all boils down to
  2164. the fact that there is no DisposeZone() call and therefore the memory
  2165. manager doesn't always know when to remove a heap from its list of active
  2166. heaps.
  2167.  
  2168. I suppose it could inspect every DisposePtr() and DisposeHandle() call to
  2169. see if the released memory contains a heap, but that is an awful lot of
  2170. overhead.
  2171.  
  2172. In article <DaveZ-1604960803590001@msn_7_2.binc.net>, DaveZ@mailbag.com
  2173. (David B. Zwiefelhofer) wrote:
  2174. > I do use the temporary memory for much longer than one loop, but I do
  2175. > unlock it before each call to WaitNextEvent.
  2176.  
  2177. If you mean the handle containing the temporary heap, allowing it to move
  2178. would definitely cause problems since the memory manager expects heaps to
  2179. stay put.
  2180.  
  2181. Dave
  2182.  
  2183. -- 
  2184. Dave Warker
  2185.      mailto: dwarker@acy.digex.net
  2186.      http://www.acy.digex.net/~dwarker/
  2187.  
  2188.  
  2189. +++++++++++++++++++++++++++
  2190.  
  2191. >From mhteas@btech.com (Malcolm H. Teas)
  2192. Date: 22 Apr 1996 19:41:18 GMT
  2193. Organization: Blaze Technology, Inc.
  2194.  
  2195. One thing that would help reduce fragmentation in your Process Manager
  2196. heap (where temp. memory is allocated) is to call MoveHHi() on the
  2197. block before it's locked.  This isn't critical in most cases though.
  2198.  
  2199. I don't see anything really terrible here.  Note that the MoreMasters()
  2200. loop (in theory) can be replaced by upping the second parm to
  2201. InitZone().
  2202.  
  2203. I'm guessing, as a result of this code, that the problem isn't in
  2204. creating the zone, but using it.
  2205.  
  2206. Malcolm  H. Teas                E-Mail: mhteas@btech.com
  2207. Blaze Technology, Inc.          Telephone: 512/502-9552
  2208. PO Box 200279                   Fax: 512/502-9554
  2209. Austin, TX USA 78720-0279       WWW: http://www.btech.com/
  2210.    ** A Macintosh software development services company  **
  2211.  
  2212.  
  2213. ---------------------------
  2214.  
  2215. End of C.S.M.P. Digest
  2216. **********************
  2217.  
  2218.  
  2219.  
  2220.